<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        司机列表添加
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/index.css">
</head>
<body>

<div class="layui-card">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>司机姓名
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" style="width: 100%;height: 36px">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>联系方式
                        </label>
                        <div class="layui-input-block">
                            <input type="text" autocomplete="off" placeholder="请输入电话"
                                   class="layui-input" lay-verify="number" name="phoneNumber" id="phoneNumber">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <input class="layui-btn" value="保存" type="button" id="bu1">
                    </div>
                </form>
                <div style="height:100px;"></div>
            </div>

        </div>
    </div>
</div>

<script src="lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="js/index.js"></script>

<script>
    document.getElementById("bu1").onclick = function () {
        var list = {
            "name": document.getElementById("name").value,
            "phoneNumber": document.getElementById("phoneNumber").value,
        };
        console.log(list);
        var lists = JSON.stringify(list);
        $.ajax({
            type: 'post',
            url: 'http://localhost:5500/driver/addDriver',
            data: lists,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                console.log(data);
                alert("添加成功");

            }, error: function (e) {//响应不成功时返回的函数
                console.log(e, 'error');
                alert("错误");
            }
        });

    };
</script>
</body>
</html>